package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 护理项目相关接口
 */
@RestController
@RequestMapping("/nursing_project")
@Api(tags = "护理项目",description = "护理项目相关接口")
public class NursingProjectController extends BaseController{
    @Autowired
    private NursingProjectService nursingProjectService;

    /**
     * 条件分页查询护理项目
     * @param pageNum 当前页码
     * @param pageSize 每页记录数
     * @param name 护理项目名称
     * @param status 护理项目的状态
     *
     */
    @ApiOperation(value = "条件分页查询护理项目",notes = "根据护理项目名称和状态进行分页查询")
    @GetMapping
    public ResponseResult<PageResponse<NursingProjectVo>> selectByPage(
            @ApiParam(value = "当前页码，用于指定要查询的页数", required = true) Integer pageNum,
            @ApiParam(value = "每页显示的记录数，用于控制每页包含的护理项目数量", required = true) Integer pageSize,
            @ApiParam(value = "护理项目的名称，可选参数，用于根据项目名称进行查询过滤") String name,
            @ApiParam(value = "护理项目的状态，可选参数，用于根据项目状态进行查询过滤") Integer status){


        return success(nursingProjectService.selectByPage(pageNum,pageSize,name,status));

    }

    /**
     * 添加护理项目
     * @param nursingProjectDto 护理项目信息
     *
     */

    @ApiOperation(value = "添加护理项目",notes = "传入护理项目信息，返回添加结果")
    @PostMapping
    public ResponseResult  addNursingProject(@RequestBody NursingProjectDto nursingProjectDto){
        return toAjax(nursingProjectService.addNursingProject(nursingProjectDto));
    }


    /**
     * 根据id查询护理项目
     */
    @GetMapping("/{id}")
    @ApiOperation(value = "根据id查询护理项目",notes = "传入护理项目的id，返回护理项目信息")
    public ResponseResult<NursingProjectVo> selectNursingProjectById(@PathVariable Long id){
        return success(nursingProjectService.selectById(id));
    }


    /**
     * 更新护理项目
     */

    @PutMapping
    @ApiOperation(value = "更新护理项目",notes = "传入护理项目信息，返回更新结果")
    public ResponseResult updateNursingProject(@RequestBody NursingProjectDto nursingProjectDto){
        return toAjax(nursingProjectService.updateNursingProject(nursingProjectDto));
    }


    /**
     * 启用禁用护理项目
     */
    @PutMapping("/{id}/status/{status}")
    @ApiOperation(value = "启用禁用护理项目",notes = "传入护理项目的id和状态，返回更新结果")
    public ResponseResult updateNursingProjectStatus(@PathVariable Long id,@PathVariable Integer status){
        return toAjax(nursingProjectService.updateNursingProjectStatus(id,status));
    }


    /**
     * 删除护理项目
     */

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除护理项目",notes = "传入护理项目的id，返回删除结果")
    public ResponseResult deleteNursingProject(@PathVariable Long id){
        return toAjax(nursingProjectService.deleteById(id));
    }


    /**
     * 查询所有护理项目
     */
    @GetMapping("/all")
    @ApiOperation(value = "查询所有护理项目",notes = "返回所有护理项目信息")
    public ResponseResult<List<NursingProjectVo>> selectAll(){
        return success(nursingProjectService.selectAll());

    }
}
